package com.example.nacosdemo.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Component;

/**
 * 应用配置类，用于封装从Nacos配置中心读取的配置
 * 使用@RefreshScope支持配置的动态刷新
 * 使用@ConfigurationProperties将配置项绑定到Bean属性
 */
@Component
@ConfigurationProperties(prefix = "app.config")
@RefreshScope
public class AppConfig {

    // 消息配置
    private String message = "Default message";

    // 版本配置
    private String version = "0.0.0";

    // 调试模式配置
    private boolean debug = false;

    // 环境配置（可在Nacos中添加）
    private String env = "dev";

    // 超时配置（可在Nacos中添加）
    private int timeout = 5000;

    // Getters and Setters
    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public boolean isDebug() {
        return debug;
    }

    public void setDebug(boolean debug) {
        this.debug = debug;
    }

    public String getEnv() {
        return env;
    }

    public void setEnv(String env) {
        this.env = env;
    }

    public int getTimeout() {
        return timeout;
    }

    public void setTimeout(int timeout) {
        this.timeout = timeout;
    }

    @Override
    public String toString() {
        return "AppConfig{" +
                "message='" + message + '\'' +
                ", version='" + version + '\'' +
                ", debug=" + debug +
                ", env='" + env + '\'' +
                ", timeout=" + timeout +
                '}';
    }
}